package com.bap.ele.workbench.intro;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchAction introAction;
    
	private IWorkbenchAction preferenceAction;

	private IWorkbenchAction perspectiveAction;

	private IWorkbenchAction exitAction;

	private IWorkbenchAction newFileAction;
    
	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
		super(configurer);
	}

	protected void makeActions(IWorkbenchWindow window) {
		introAction = ActionFactory.INTRO.create(window);
		register(introAction);
	
		preferenceAction = ActionFactory.PREFERENCES.create(window);
		register(preferenceAction);
		
		newFileAction  = ActionFactory.NEW.create(window);
		register(newFileAction);
		
		exitAction = ActionFactory.QUIT.create(window);
		register(exitAction);
		
		perspectiveAction = ActionFactory.PREVIOUS_PERSPECTIVE.create(window);
		register(perspectiveAction);
	}

	protected void fillMenuBar(IMenuManager menuBar) {
		MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
		menuBar.add(fileMenu);
		MenuManager windowMenu = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW);
		menuBar.add(windowMenu);
		MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
		menuBar.add(helpMenu);
		
		//File
		fileMenu.add(exitAction);
		fileMenu.add(newFileAction);
		
		// Help
		helpMenu.add(introAction);
		
		//Window
		windowMenu.add(preferenceAction);
//		windowMenu.add(perspectiveAction);
	}

}
